<template>
  <div class="fui-fullHigh-group">
    <div class="fui-fullHigh-item menu">
      <div
        class="nav"
        :class="on == index ? 'on' : ''"
        @click="edit_cat(index)"
        v-for="(item, index) in cat"
        :key="item.cid"
      >
        {{ item.name }}
      </div>
    </div>
    <div class="fui-fullHigh-item container">
      <div
        class="fui-icon-group"
        v-for="(item, index) in cat[on].son"
        :key="item.cid"
      >
        <router-link :to="`/goods_lists?id=${item.cid}`">
          <div class="fui-icon-col">
            <div class="icon">
              <img class="img" :src="item.pic" />
            </div>
            <div class="text">{{ item.name }}</div>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>
<script>
import { reactive, toRefs } from "vue";
import { GoodsIndex } from "../../network/index.js";

export default {
  setup() {
    const data = reactive({
      on: 0,
      cat: [],
    });
    const edit_cat = (e) => {
      data.on = e;
    };
    GoodsIndex().then((e) => {
      data.cat = e;
    });
    return {
      title: "分类",
      ...toRefs(data),
      edit_cat,
    };
  },
};
</script>
<style scoped>
.fui-fullHigh-group {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
}
/* 左侧 */
.fui-fullHigh-item {
  height: inherit;
  width: 100%;
  background: #fff;
  overflow-y: auto;
}
.fui-fullHigh-item.menu {
  width: 5.25rem;
  background: #f8f8f8;
}
.fui-fullHigh-item.menu .nav {
  font-size: 28rpx;
  text-align: center;
  color: #000;
  padding: 0.2rem 0;
  height: 2.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: Center;
}
.fui-fullHigh-item.menu .on {
  background: #fff;
  position: relative;
  color: #ff5555;
}
/* 右侧 */
.fui-fullHigh-item.container {
  position: relative;
  padding: 0.8rem;
  flex: 1;
}
.fui-icon-group {
  position: relative;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  width: 45%;
  max-height: 161px;
}
.fui-icon-group .fui-icon-col {
  height: auto;
  position: relative;
  padding: 0.5rem 0;
  text-align: center;
  transition: background-color 300ms;
  -webkit-transition: background-color 300ms;
  float: left;
  border: none !important;
}
.fui-icon-group .fui-icon-col {
  float: left;
  margin-right: 17px;
  padding-top: 10px;
}
.fui-icon-group .fui-icon-col .icon {
  height: 115px;
  width: 100%;
  margin: auto;
  text-align: center;
  line-height: 2.2rem;
}
.icon {
  font-family: "icon" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.img {
  width: 115px;
  height: 100%;
}
.fui-icon-group .fui-icon-col .text {
  font-size: 24px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.2rem;
  color: #000;
}
.fui-icon-group .fui-icon-col .text {
  font-size: 0.55rem;
  line-height: 1.05rem;
  padding-top: 0.5rem;
}
</style>